Flag tag score is a long value in milliseconds

So, pull value, divide by 3600, and bam!  You've got minutes held.

However, you can't do this simply when you pull scoring.  You can only do this when it determines stage end.  why?  Otherwise you'll get a lot of ties...

as written should work.  give it a whirl in a rom.  flag confirmed with code as-is, but need to test all other scenarios (and probably flag more)


//7F0BEF04:	0xF3A34-E
11E00009	*BEQ	T7,R0,7F0BEF2C	skip this if player is alive
8C4E0424	*LW	T6,0424 (V0)	1 when dying
11C00006	*BEQ	T6,R0,7F0BEF28
8C580428	*LW	T8,0428 (V0)	1 when screen fading to black
13000004	*BEQ	T8,R0,7F0BEF28
C44803E4	*LWC1	F8,03E4 (V0)
4608003E	*C.LE.S	F0,F8
00000000	*NOP
45020001	*BC1TL	7F0BEF2C
24A50001	*ADDIU	A1,A1,0001
//7F0BEF2C:
AFA3001C	*SW	V1,001C (SP)	80079EE0	player data pointers
AFA40174	*SW	A0,0174 (SP)	player# being tested
AFA50170	*SW	A1,0170 (SP)	nonzero if player dead or dying?
AFA6016C	*SW	A2,016C (SP)	if nonzero indicates a winner
//7F0BEF3C:
0FC30E36	*JAL	7F0C38D8	returns V0=score; copies from A0
//7F0BEF40:	compute and compare scores
AFA70178	*SW	A3,0178 (SP)
0FC051D6	*JAL	7F014758	returns V0=scenario
340E0002	*ORI	T6,R0,0002
144E0003	*BNE	V0,T6, +3
340E0E10	*ORI	T6,R0,0E10
008E001A	*DIV	A0,T6
00002012	*MFLO	A0
0FC04111	*JAL	7F010444	V0=score (not f/ buffer though...)
8FA3001C	LW	V1,001C (SP)	V1=player data pointer
0082|082A	*SLT	AT,A0,V0	TRUE if max score < score (copy)
LW	A0,0174 (SP)
LW	A1,0170 (SP)
LW	A2,016C (SP)
BNEZ	AT,7F0BEF80
LW	A3,0178 (SP)
ADDIU	A2,A2,0001	A2++	indicate a winner
//7F0BEF80:
ADDIU	A0,A0,0001	A0++
SLT	AT,A0,A3	TRUE if nextplayer# < maxplayer#
BNEZ	AT,7F0BEEFC	CHECK NEXT PLAYER DATA
ADDIU	V1,V1,0004
BLEZ	A2,7F0BEFB8	no winner yet...
NOP
BNEZ	A1,7F0BEFB0	stop play...
NOP
JAL	7F0C2530
OR	A0,R0,R0
BEQ	R0,R0,7F0BEFB8
NOP
//7F0BEFB0:
JAL	7F0C2520	1->8008C700	stop play
NOP

==========================================
==========================================
==========================================
holding flag hacking

This routine needs to set flag to left hand.  trickier than it seems:
//7F0BFA30:	this is used to force the flag out when owned
	0xF4560-E
	JAL	7F014758	V0=scenario
	SWC1	F6,0038 (V0)
	ADDIU	AT,R0,0002
	BNE	V0,AT,7F0BFAD0	skip if not flag tag
	NOP
	JAL	7F08CF80	V0=1 if flag held
	NOP
	BEQ	V0,R0,7F0BFAC0	skip if flag not held
	NOP
	JAL	7F05D9D0	V0=weapon# in use
24040001	*ADDIU	A0,R0,0001	check *left gun (A0=1)
	ADDIU	AT,R0,0058
	BEQ	V0,AT,7F0BFA90	if flag already set get to scoring
24040001	*ADDIU	A0,R0,0001	draw *left weapon (A0=1)
0FC176D5	JAL	7F05DB54	*3rd person draw weapon
	ADDIU	A1,R0,0058	draw flag (A1=58)
	LUI	V0,8008
	LW	V0,A0B0 (V0)	V0=current player data
	ADDIU	AT,R0,0002	AT=2
	ADDIU	T1,R0,0005	T1=5
	LW	T0,0894 (V0)	FIDDLE with the weapon state flag
	BNE	T0,AT,7F0BFA90	if playerdata+0x894==2, set to 5
	NOP
	SW	T1,0894 (V0)	set playerdata+0x894 to 5
//7F0BFA90:	advance flag time and set flag ownership
	LUI	V1,8008
	ADDIU	V1,V1,A0B4
	LW	V0,0000 (V1)	V0=current player stat pointer
	LUI	T3,8005
	LW	T3,8374 (T3)	T3=1 if not paused (used to advance flag time)
	LW	T2,0060 (V0)	T2=flag held time
	ADDIU	T5,R0,0001
	ADDU	T4,T2,T3
	SW	T4,0060 (V0)	advance flag held time one more millisecond
	LW	T6,0000 (V1)	T6=current player stat pointer
	BEQ	R0,R0,7F0BFB10
	SB	T5,0069 (T6)	1->flag byte
//7F0BFAC0:	flag not held...
	LUI	T7,8008
	LW	T7,A0B4 (T7)	T7=current player stat pointer
	BEQ	R0,R0,7F0BFB10
	SB	R0,0069 (T7)	blank the flag byte
//7F0BFAD0:
	JAL	7F014758
	NOP


This disables weapon selection
//7F083DD8:	flag-specific code
	0xB890F-E
0FC233E0	JAL	7F08CF80	return V0=1 if holding flag
00000000	NOP
50400003	BEQL	V0,R0,7F083DF0
8FAB0074	LW	T3,0074 (SP)
00000000	*NOP	{0xB8918}
8FAB0074	LW	T3,0074 (SP)	T3=1


-------------------------------
0FC17674	JAL	7F05D9D0	V0=weapon# in use
24040001	*ADDIU	A0,R0,0001	check *left gun (A0=1)
24010058	ADDIU	AT,R0,0058
1041000B	BEQ	V0,AT,7F0BFA90	if flag already set get to scoring
8DC90894	LW	T1,0894 (T6)	//T6 is from 7F05D9D0; weapon state
14090009	BNE	T1,R0,7F0BFA90	if weapon at rest, set flag
24040001	*ADDIU	A0,R0,0001	draw *left weapon (A0=1)
0FC176D5	JAL	7F05DB54	*3rd person draw weapon
24050058	ADDIU	A1,R0,0058	draw flag (A1=58)
0FC17674	JAL	7F05D9D0	V0=weapon# in use
00002025	OR	A0,R0,R0
0FC176D5	JAL	7F05DB54	*3rd person draw weapon
00022825	OR	A1,R0,V0
	NOP
	SW	T1,0894 (V0)	set playerdata+0x894 to 5

NAH, THIS SHOULD WORK THOUGH:
	7F0BFA30	0xF4560-E
0FC17674	JAL	7F05D9D0	V0=weapon# in use
24040001	*ADDIU	A0,R0,0001	check *left gun (A0=1)
24010058	ADDIU	AT,R0,0058
1041000B	BEQ	V0,AT,7F0BFA90	if flag already set get to scoring
8DC90894	*LW	T1,0894 (T6)	//T6 is from 7F05D9D0; weapon state
24080008	*ADDIU	T0,R0,0008
15090008	*BNE	T0,T1,7F0BFA90
24040001	*ADDIU	A0,R0,0001
0FC176D5	*JAL	7F05DB54
24050058	*ADDIU	A1,R0,0058
*nop
*nop
*nop
nop
*nop
fill with spaces!


slight issue with above.  It sometimes works.  This is more accurate, though still problematic
0FC17674	JAL	7F05D9D0	V0=weapon# in use
24040001	*ADDIU	A0,R0,0001	check *left gun (A0=1)
24010058	ADDIU	AT,R0,0058
1041000B	BEQ	V0,AT,7F0BFA90	if flag already set get to scoring
8DC90894	*LW	T1,0894 (T6)	//T6 is from 7F05D9D0; weapon state
24080008	*ADDIU	T0,R0,0008
15090008	*BNE	T0,T1,7F0BFA90
24040001	*ADDIU	A0,R0,0001
0FC176D5	*JAL	7F05DB54
24050058	*ADDIU	A1,R0,0058
0FC17674	*JAL	7F05D9D0
00002025	*OR	A0,R0,R0
00002025	*OR	A0,R0,R0
0FC176D5	*JAL	7F05DB54
00022825	*OR	A1,R0,V0

following works if you open fire.  otherwise, will continuously draw weapon
7F0BFA50:
OR	A0,R0,R0
JAL	7F05D9D0
ADDIU	AT,R0,0058
BEQ	V0,AT,7F0BFA90
NOP
JAL	7F05D9D0
ADDIU	A0,R0,0001
BEQ	V0,AT,7F0BFA90
NOP
JAL	7F05D9D0
OR	A0,R0,R0
JAL	7F05D914
OR	A1,R0,V0
ADDIU	A0,R0,0001
JAL	7F05D914
ADDIU	A1,R0,0058


THIS MIGHT WORK TOO:
7F0BFA50:
24040001	ADDIU	A0,R0,0001
0FC17674	JAL	7F05D9D0
24010058	ADDIU	AT,R0,0058
1041000C	BEQ	V0,AT,7F0BFA90	[or do I want to jump to -80?]
00002025	OR	A0,R0,R0
0FC17674	JAL	7F05D9D0
24010002	ADDIU	AT,R0,0002
0FC17645	JAL	7F05D914
00022825	OR	A1,R0,V0
24040001	ADDIU	A0,R0,0001
0FC17645	JAL	7F05D914
24050058	ADDIU	A1,R0,0058
8D220894	LW	V0,0894 (T1)	[not so certain this is always =]
24050005	ADDIU	A1,R0,0005
50450001	BEQL	V0,A1,7F0BFA90
AD210894	SW	AT,0894 (T1)

refine...
24040001	ADDIU	A0,R0,0001
0FC17674	JAL	7F05D9D0
24050058	ADDIU	A1,R0,0058
10450008	BEQ	V0,A1,7F0BFA80
24010002	ADDIU	AT,R0,0002
0FC17674	JAL	7F05D9D0
00002025	OR	A0,R0,R0
0FC17645	JAL	7F05D914
00022825	OR	A1,R0,V0
24040001	ADDIU	A0,R0,0001
0FC17645	JAL	7F05D914
24050058	ADDIU	A1,R0,0058
8D220894	LW	V0,0894 (T1)	[not so certain this is always =]
24050005	ADDIU	A1,R0,0005
50450001	BEQL	V0,A1,7F0BFA90
AD210894	SW	AT,0894 (T1)

doesn't work, since you place gun in hand but replace to fire...
test if 5 first...
result:  it does actually put the flag out properly, but then there isn't a way to change weapons.  Aegh...
24040001	ADDIU	A0,R0,0001
0FC17674	JAL	7F05D9D0
24010002	ADDIU	AT,R0,0002
8DC90C3C	LW	T1,0C40 (T6)
24050005	ADDIU	A1,R0,0005
50A90001	BEQL	T1,A1, +1
ADC10C3C	SW	AT,0C40 (T6)
24010058	ADDIU	AT,R0,0058
10410008	BEQ	V0,AT,7F0BFA90
00000000	NOP
0FC17674	JAL	7F05D9D0
00002025	OR	A0,R0,R0
0FC17645	JAL	7F05D914
00022825	OR	A1,R0,V0
24040001	ADDIU	A0,R0,0001
0FC17645	JAL	7F05D914
24050058	ADDIU	A1,R0,0058
--------7F0B7A94:
3C038008	LUI	V1,8008
8C62A0B4	LW	V0,A0B4 (V1)
...
7F0B7AB4:	8C6E0000->8C6EA0B4


how about this:
 use the initial pickup call to load doubles with flag left.  Use above routine to just lock the flag, probably by firing, which is probably the default action anyway
7F0503F0:	test if remote mines
	ADDIU	AT,R0,001D
	LB	A0,0080 (T5)
	*BNE	A0,AT,7F05040C
	ADDIU	AT,R0,0058
//7F000400:	add detonator too!
	JAL	7F08C488
	ADDIU	A0,R0,001E
	BEQ	R0,R0,7F050428
	LW	T6,006C (SP)
//7F050410:	Test if collected item is the flag.  If so, place in hand
	*BNE	A0,AT,7F050424	[beq r0,r0 etc	10000003 disables flag draw thingy]
	*ADDIU	A1,R0,0001
	JAL	7F05D914
	OR	A0,R0,R0
	OR	A0,R0,R0
//7F050424:	I think this is the left-hand weapon test
	*NOP
	*LW	T6,006C (SP)
	*LW	T9,0048 (SP)	//T9=object data pointer
	*LW	T7,0064 (T6)	//This should be the runtime bitflag field being tested for 00000400
	*ANDI	T8,T7,0400
	*BEQ	T8,R0,7F0504A4
	LB	T0,0080 (T9)
	SLTI	AT,T0,0021
